package com.fubowen.reader.db.bean

import android.view.View
import androidx.annotation.IntDef
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.Index
import androidx.room.PrimaryKey
import com.fubowen.reader.adapter.ISimple
import com.fubowen.reader.databinding.HistoriesBinding
import com.fubowen.reader.extension.setImageByteArray
import com.fubowen.reader.db.model.Tree

@Entity(indices = [Index(value = ["absolutePath"], unique = true)])
class Task @JvmOverloads constructor(
    val absolutePath: String = "",
    var name: String = "",
    @Status
    var status: Int = 0,
    @PrimaryKey(autoGenerate = true)
    var id: Int = 0,
) : ISimple<Task> {


    override fun isSame(new: Task) = absolutePath == new.absolutePath

    override fun isSameOfContent(new: Task) = absolutePath == new.absolutePath

    override fun onBind(view: View, id: Int) {
//        val binding = HistoriesBinding.bind(view)
//        binding.name.text = name
//        binding.url.text = url
//        binding.favicon.setImageByteArray(favicon)
    }

    companion object {
        const val STATUS_RUNNING = 0
        const val STATUS_WAITING = 1
    }
    @IntDef(Task.STATUS_RUNNING, Task.STATUS_WAITING)
    @Retention(AnnotationRetention.SOURCE)
    annotation class Status
}